package com.chx.mapper;

import com.chx.annotation.AutoFillOrder;
import com.chx.dto.PurchaseOrderPageQueryDto;
import com.chx.entity.PurchaseOrders;
import com.chx.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Author cp-月入过万
 * @Date 2025/5/30
 */
@Mapper
public interface PurchaseOrderMapper {
    @AutoFillOrder(OperationType.INSERT)
    void insert(PurchaseOrders purchaseOrders);

    @AutoFillOrder(OperationType.UPDATE)
    void update(PurchaseOrders purchaseOrders);

    @Select("select * from purchase_orders where order_id = #{id}")
    PurchaseOrders getById(Long id);

    Page<PurchaseOrders> page(PurchaseOrderPageQueryDto purchaseOrderPageQueryDto);

    @Select("select count(*) as total from purchase_orders where supplier_id = #{id}")
    int getProductById(Long id);
}
